package cn.teleware.api.vo;

import cn.teleware.api.annotation.WeakPassword;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.GroupSequence;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;

/**
 * @author : hongsw
 * @date : 2020-11-12-8:59
 * @descriptions :
 */
@Data
public class UserVO {
    @NotEmpty(message = "电话不能为空")
    @Length(min = 11, max = 11, message = "电话号码必须11位", groups = {GroupA.class})
    @Length(min = 12, max = 12, message = "电话号码必须12位", groups = {GroupB.class})
    private String phone;

    @NotEmpty(message = "密码不能为空")
    @Length(min = 6, max = 20, message = "密码必须为6-20位")
    @WeakPassword
    private String password;

    @Email(message = "邮箱格式不正确", groups = {First.class, GroupB.class})
    @NotEmpty(message = "邮箱不能为空", groups = {Second.class, GroupB.class})
    private String email;

    /**
     * l
     * 校验分组
     * 【解决】同一个校验实体类，对于不同接口的使用不同的校验规则
     *
     * @author hongsw
     * @date 2020/11/12 14:15
     **/
    public interface GroupA {
    }

    public interface GroupB {
    }


    /**
     * 组序列
     * 【解决】同一个字段，上不同校验规则的校验顺序
     *
     * @author hongsw
     * @date 2020/11/12 14:14
     **/
    @GroupSequence({First.class, Second.class})
    public interface Group {
    }

    public interface First {
    }

    public interface Second {
    }
}
